package com.person.hold.action;

import java.util.List;

import com.person.base.model.BaseUser;
import com.person.commons.struts2.BaseAction;
import com.person.commons.utils.Constants;
import com.person.commons.utils.FlipPageInfo;
import com.person.dic.model.Dic;
import com.person.hold.model.Hold;
import com.person.hold.service.HoldService;
import com.person.title.model.TitleFunc;

@SuppressWarnings("serial")
public class HoldAction extends BaseAction {
	
	private Hold hold;
	private HoldService holdService;
	private FlipPageInfo flipData=new FlipPageInfo();
	private String holdId;
	private List<Dic> dicsHold;
	private TitleFunc titleFunc;
	
	public String index(){
		flipData=holdService.findAllHoldList(flipData);
		return "listHold";
	}
	/**
	 * 弹出回复留言对话框
	 * @return
	 */
	public String revertHold(){
		//获得登陆用户身份
		BaseUser user = (BaseUser) request.getSession().getAttribute(Constants.SESSION_USER);
		//从字典获取心情表情
		dicsHold=holdService.findHoldFromDic("HOLD");
		hold=holdService.findHoldById(holdId);
		titleFunc=holdService.findTitleFuncByFuncId(hold.getFuncId());
		return "revertHold";
	}
	/**
	 * 保存回复内容
	 */
	public String saveRevertHold(){
		holdService.updateHold(hold);
		return index();
	}
	/**
	 * 点击未审核状态，变为已审核状态
	 * @return
	 */
	public String audit(){
		hold=holdService.findHoldById(holdId);
		hold.setHoldFlag("1");
		holdService.updateHold(hold);
		return index();
	}
	public String deleteHold(){
		hold=holdService.findHoldById(holdId);
		holdService.deleteHold(hold);
		return index();
	}
	/**
	 * @return the flipData
	 */
	public FlipPageInfo getFlipData() {
		return flipData;
	}

	/**
	 * @param flipData the flipData to set
	 */
	public void setFlipData(FlipPageInfo flipData) {
		this.flipData = flipData;
	}

	/**
	 * @param holdService the holdService to set
	 */
	public void setHoldService(HoldService holdService) {
		this.holdService = holdService;
	}
	/**
	 * @return the hold
	 */
	public Hold getHold() {
		return hold;
	}
	/**
	 * @param hold the hold to set
	 */
	public void setHold(Hold hold) {
		this.hold = hold;
	}
	/**
	 * @return the holdId
	 */
	public String getHoldId() {
		return holdId;
	}
	/**
	 * @param holdId the holdId to set
	 */
	public void setHoldId(String holdId) {
		this.holdId = holdId;
	}
	/**
	 * @return the dicsHold
	 */
	public List<Dic> getDicsHold() {
		return dicsHold;
	}
	/**
	 * @param dicsHold the dicsHold to set
	 */
	public void setDicsHold(List<Dic> dicsHold) {
		this.dicsHold = dicsHold;
	}
	/**
	 * @return the titleFunc
	 */
	public TitleFunc getTitleFunc() {
		return titleFunc;
	}
	/**
	 * @param titleFunc the titleFunc to set
	 */
	public void setTitleFunc(TitleFunc titleFunc) {
		this.titleFunc = titleFunc;
	}
	
	
}